import Vue from 'vue'
import Router from 'vue-router';

Vue.use(Router);
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}; //解决点击两下出现 NavigationDuplicated {_name: "NavigationDuplicated"}

/*
keepAlive 页面缓存
  closable  页签是否关闭
  title     页面名称,
  bar       是否是左侧菜单
 */
// 默认路由，不需要权限
export const constantRouterMap = [{
    path: '/',
    redirect: '/Login',
    hidden: true
  },
  {
    path: '/Login',
    name: 'Login',
    component: resolve => require(['@/views/Login'], resolve),
  },
  {
    path: '/Index',
    name: 'Index',
    component: resolve => require(['@/views/Index'], resolve),
    children: []
  },
  //需要注意这里，404的路由一定要写在静态路由中,但捕获未定义路由配置一定要放在动态路由里
  {
    path: '/Error',
    name: 'Error',
    component: resolve => require(['@/views/Error'], resolve),
    meta: {
      keepAlive: false,
      title: '错误页面'
    },
  },
];

/*
异步挂载的路由
动态需要根据权限加载的路由表
*/
export const asyncRouterMap = [{
    path: '/Home',
    name: 'Home',
    component: resolve => require(['@/views/Home'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '首页',
    },
  },
  {
    path: "/MemberControl",
    name: 'MemberControl',
    component: resolve => require(['@/views/Member/MemberControl'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: false,
      title: "商家管理",
    },
  },
  {
    path: "/BannerList",
    name: 'BannerList',
    component: resolve => require(['@/views/Member/BannerList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: false,
      title: "商户管理",
    },
  },
  {
    path: '/Test',
    name: 'Test',
    component: resolve => require(['@/views/User/Test'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: false,
      title: '测试'
    },
  },

  {
    path: '/GoodsList',
    name: 'GoodsList',
    component: resolve => require(['@/views/Goods/GoodsList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '商品列表'
    },
  },

  {
    path: '/UserControl',
    name: 'UserControl',
    component: resolve => require(['@/views/User/UserControl'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '用户列表'
    },
  },

  {
    path: '/BannerContent',
    name: 'BannerContent',
    component: resolve => require(['@/views/AppLet/BannerContent'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: 'Banner管理'
    },
  },
  {
    path: '/GoodsDefault',
    name: 'GoodsDefault',
    component: resolve => require(['@/views/AppLet/GoodsDefault'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '商品默认介绍管理'
    },
  },

  {
    path: '/RecommendGoods',
    name: 'RecommendGoods',
    component: resolve => require(['@/views/AppLet/RecommendGoods'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '推荐商品管理'
    },
  },
  {
    path: '/MenuSkuList',
    name: 'MenuSkuList',
    component: resolve => require(['@/views/Goods/MenuSkuList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: false,
      title: '菜品的规格管理'
    },
  },
  {
    path: '/MenuTastes',
    name: 'MenuTastes',
    component: resolve => require(['@/views/Goods/MenuTastes'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: false,
      title: '菜品的口味管理'
    },
  },
  {
    path: '/ProjectList',
    name: 'ProjectList',
    component: resolve => require(['@/views/Project/ProjectList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '商户结算'
    },
  },
  {
    path: '/AgentContent',
    name: 'AgentContent',
    component: resolve => require(['@/views/Project/AgentContent'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '代理商结算'
    },
  },
  {
    path: '/DiscountList',
    name: 'DiscountList',
    component: resolve => require(['@/views/Discount/DiscountList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '优惠券列表'
    },
  },
  {
    path: '/GrantData',
    name: 'GrantData',
    component: resolve => require(['@/views/Discount/GrantData'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '发放详情'
    },
  },
  {
    path: '/LockerList',
    name: 'LockerList',
    component: resolve => require(['@/views/Locker/LockerList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '设备管理'
    },
  },
  {
    path: '/Advertising',
    name: 'Advertising',
    component: resolve => require(['@/views/Locker/Advertising'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '设备广告'
    },
  },
  {
    path: '/BoxList',
    name: 'BoxList',
    component: resolve => require(['@/views/Locker/BoxList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: false,
      title: '格口列表'
    },
  },
  {
    path: '/SizeList',
    name: 'SizeList',
    component: resolve => require(['@/views/Locker/SizeList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: false,
      title: '柜口尺寸列表'
    },
  },
  {
    path: '/DeliverList',
    name: 'DeliverList',
    component: resolve => require(['@/views/Deliver/DeliverList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '鉴定中心'
    },
  },
  {
    path: '/DeliverLockerList',
    name: 'DeliverLockerList',
    component: resolve => require(['@/views/Deliver/DeliverLockerList'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: false,
      title: '初鉴'
    },
  },
  {
    path: '/MenuOrders',
    name: 'MenuOrders',
    component: resolve => require(['@/views/Order/MenuOrders'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '会员订单列表'
    },
  },
  {
    path: '/DeliverOrders',
    name: 'DeliverOrders',
    component: resolve => require(['@/views/Order/DeliverOrders'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '商家订单列表'
    },
  },
  {
    path: '/StoreLog',
    name: 'StoreLog',
    component: resolve => require(['@/views/Order/StoreLog'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '预存付款记录'
    },
  },
  {
    path: '/AuthRole',
    name: 'AuthRole',
    component: resolve => require(['@/views/Role/AuthRole'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '角色列表'
    },
  },
  {
    path: '/AuthUser',
    name: 'AuthUser',
    component: resolve => require(['@/views/Role/AuthUser'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '员工管理'
    },
  },
  {
    path: '/AuthMenu',
    name: 'AuthMenu',
    component: resolve => require(['@/views/Role/AuthMenu'], resolve),
    meta: {
      keepAlive: false,
      closable: true,
      bar: true,
      title: '权限列表'
    },
  }
];
export default new Router({
  mode: 'hash',
  routes: constantRouterMap
})
